package starComponent.experiments.expeComparison;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.io.IOException;

import starComponent.experiments.expedependencies.E_Experiment;
import tuio.components.ButtonTouch;

public class ListenerStart implements ActionListener{
	
	private boolean isRunning = false;
	private ButtonTouch button;
	private TraceExperiment trace;
	

	public ListenerStart(A_Expe2Comparison parent, ButtonTouch button, int groupNumber, E_Experiment expType, String branchToObserve, double valueToValidate, int validationMode){
		this.button = button;
		trace = new TraceExperiment(parent, expType, groupNumber, branchToObserve, valueToValidate, validationMode);
	}

	@Override
	public void actionPerformed(ActionEvent e) {
		if(!isRunning){
			button.setText("Cancel");
			trace.start();
			isRunning = true;
		}
		else{
			button.setText("Start");
			try {
				trace.cancel();
			} catch (IOException e1) {
				e1.printStackTrace();
			}
			isRunning = false;
		}
	}

	
	
	public TraceExperiment getTrace() {
		return trace;
	}

	public void setTrace(TraceExperiment trace) {
		this.trace = trace;
	}


}
